package com.zz.parkingsystem.controller.admin;

import com.zz.parkingsystem.entity.Weekday;
import com.zz.parkingsystem.entity.Weekend;
import com.zz.parkingsystem.service.PCStrService;
import com.zz.parkingsystem.util.Result;
import com.zz.parkingsystem.util.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "路段收费策略")
@RequestMapping("admin/str")
public class AdminStrController {
    @Resource
    private PCStrService pcStrService;

    @ApiModelProperty(value = "插入周内收费策略信息")
    @PostMapping("addStrN/{id}")
    public Result addStrN(@PathVariable("id") long id, @RequestBody Weekday weekday){
        int i = pcStrService.insertSelective(weekday);
        return ResultGenerator.genSuccessResult("插入周内策略信息成功");
    }

    @ApiOperation(value = "插入周末收费策略信息")
    @PostMapping("addStrM/{id}")
    public Result addStrM(@PathVariable("id") long id, @RequestBody Weekend weekend){
        int i = pcStrService.insertSelective(weekend);
        return ResultGenerator.genSuccessResult("插入周末策略信息成功");
    }

    @ApiOperation(value = "修改周内策略信息")
    @PutMapping("/updateN/{id}")
    public Result updateStrN(@PathVariable("id") Long id,@RequestBody Weekday weekday){
        int i = pcStrService.updateByPrimaryKeySelective(weekday);
        return ResultGenerator.genSuccessResult("修改周内策略信息成功");
    }
    @ApiOperation(value = "修改周末策略信息")
    @PutMapping("updateM/{id}")
    public Result updateStrM(@PathVariable("id") long id,@RequestBody Weekend weekend){
        int i = pcStrService.updateByPrimaryKeySelective(weekend);
        return ResultGenerator.genSuccessResult("修改周末策略信息成功");
    }
}
